package com.zndroid.layertree.bean;

import android.os.Build;

import java.util.List;
import java.util.Objects;

public abstract class ABaseData<T> implements IBean<T> {
    private long id;
    private List<T> subList;

    @Override
    public long getId() {
        return id;
    }

    @Override
    public void setId(long id) {
        this.id = id;
    }

    @Override
    public void setSubList(List<T> subList) {
        this.subList = subList;
    }

    @Override
    public List<T> getSubList() {
        return subList;
    }

    @Override
    public boolean isSub() {
        return subList == null || subList.size() == 0;
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) return true;
        if (object == null || getClass() != object.getClass()) return false;
        ABaseData<?> baseBean = (ABaseData<?>) object;
        return id == baseBean.id;
    }

    @Override
    public int hashCode() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            return Objects.hash(id);
        }

        int hash = 5;
        hash = 67 * hash + (int)(this.id ^ (this.id >>> 32));

        return hash;
    }
}
